package com.polaris.live.dialog.common

import android.content.Context
import com.lxj.xpopup.XPopup
import com.lxj.xpopup.core.CenterPopupView
import com.polaris.live.R
import com.polaris.live.databinding.DialogTipsBinding

/**
 * 确认弹窗
 *
 * @author Created by lucas on 2023/10/28 09:28
 */
class TipsDialog(
    context: Context,
    private val title: String?,
    private val content: String,
) : CenterPopupView(context) {

    private lateinit var mBinding: DialogTipsBinding

    override fun getImplLayoutId(): Int {
        return R.layout.dialog_tips
    }

    override fun onCreate() {
        super.onCreate()
        mBinding = DialogTipsBinding.bind(popupImplView)

        mBinding.tvContent.text = content
        title?.let {
            mBinding.tvTitle.text = it
        }
    }


    companion object {

        fun show(
            context: Context,
            title: String?,
            content: String,
        ) {
            XPopup.Builder(context)
                .dismissOnTouchOutside(true)
                .dismissOnBackPressed(true)
                .isDestroyOnDismiss(true)
                .asCustom(
                    TipsDialog(
                        context,
                        title,
                        content
                    )
                )
                .show()
        }

    }
}